<?php

namespace App\Models;



class SysLoginLog extends ApiBaseModel
{

    protected $table = 'sys_login_log';
    protected $fillable = [
        'username',
        'login_ip',
        'user_id',
        'request_param',
        'created_at',
        'updated_at',
        'remark'
    ];

    public static function createLog($user, $request,  $remark){
        $params = $request->all();
        self::create([
            'username' => $user['username'] ?? '无',
            'login_ip'  => $request->ip(),
            'user_id'  => $user['id'] ?? 0,
            'remark' => $remark,
            'request_param' => is_array($params) ? json_encode($params) : $params,
        ]);
    }

}
